<template>
  <div class="page">
    <div class="head">
      <h1>操作记录</h1>
    </div>
    <div class="panel">
      <ul class="list">
        <li v-for="(item,index) in records" :key="index">
          <div class="info">
            <p>{{ item | coinRecordType }}</p>
            <span>{{ item.createTime | formatTime }}</span>
          </div>
          <div class="status">
            <p>{{ item.status ? '已完成' : '待处理' }}</p>
            <span :class="item.type==1||item.type==2 ? 'green':'red'">{{ item.type==1||item.type==2 ? '-' : '+' }}{{ item.amount }}</span>
          </div>
        </li>
        <infinite-loading @infinite="initData" ref="infiniteLoading2">
          <span slot="no-more"></span>
          <div slot="no-results">
            <br>
            <empty></empty>
          </div>
          <spinner slot="spinner" type="lines"></spinner>
        </infinite-loading>
      </ul>
    </div>
  </div>
</template>

<script>
  import {
    Spinner,
    Cell,
    Group
  } from 'vux'
  import empty from './common/empty.vue'
  import InfiniteLoading from 'vue-infinite-loading';
  export default {
    components: {
      empty,
      InfiniteLoading,
      Spinner,
      Cell,
      Group
    },
    data() {
      return {
        records: [],
        current: 1,
        filters: [
        	{name: '全部', value: 0},
        	{name: '提现', value: 1},
        	{name: '挂单扣减', value: 2},
        	{name: '交易取消退款', value: 3},
        	{name: '交易获得', value: 4}
        ],
        type: 1
      }
    },
    mounted() {
      this.$nextTick(function() {
        this.type = this.$route.query.t
      });
    },
    methods: {
      initData($state) {
        this.$http
          .post(`/users/coinRecordPage`, {
            current: this.current,
            coinType: this.type
          })
          .then(res => {
            if (res.code == 200) {
              if (res.result.total > 0) {
                this.records = this.records.concat(res.result.records);
                $state.loaded();
                if (res.result.current < res.result.pages) {
                  this.current += 1;
                } else {
                  $state.complete();
                }
              } else {
                $state.complete();
              }
            } else {}
          })
          .catch(function(error) {});
      }
    }
  }
</script>

<style lang="scss" scoped>
  .panel {
    padding-bottom: 100px;
  }
  .filter-wrap {
    margin: 0 8px 10px;
  }
  .filter {
    padding: 0 12px 0;
    font-size: 12px;
    max-height: 0;
    transition: .3s;
    li {
      background: #f6f6f6;
      margin: 0 5px 5px 0;
      padding: 0 5px;
      border-radius: 2px;
      display: inline-block;
      color: #7e7e7e;
      transition: .5s;
    }
    .active {
      color: #fff;
      background: $tmdark;
    }
  }
  .animate {
    max-height: 150px;
  }
  .list {
    li {
      border-bottom: 1px solid #dfdfdf;
      display: flex;
      justify-content: space-between;
      align-items: flex-end;
      padding: 5px 0;
      .info {
        color: $tmdark;
        p {
          font-size: 17px;
        }
        span {
          font-size: 14px;
        }
      }
      .status {
        text-align: right;
      }
      &>span {
        font-size: 20px;
      }
      .red {
        color: $red;
      }
      .green {
        color: $green;
      }
    }
  }
</style>
<style lang="scss">
  .filter-wrap {
    // margin: 0 8px 10px;
    .vux-no-group-title {
      border-radius: 8px;
      overflow: hidden;
      box-shadow: 0px 4px 12px 0px rgba(158, 158, 158, 0.3);
    }
    .weui-cells:before {
      display: none;
    }
  }
</style>